package com.zzx.graduation.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;

@Getter
@Setter
//@Proxy(lazy = true)//,默认开启懒加载
@Entity//jpa实体类和数据表映射
//@Table(name="tb_user")//指定和哪个表对应，省略就采用默认user
//@JsonIgnoreProperties(value = {"fans","visitors"})//需要一一列出需要忽略转json的属性，
// 还是在属性上面添加好一点
public class News {
    @Id//主键
    @GeneratedValue(strategy = GenerationType.IDENTITY)//自增主键
    private Integer id;

    @Column(name="source_id")
    private Integer sourceId;
//    @Column(name="source_type")
//    private String sourcetType;//源类型 0：员工  1：群聊

    @Column(name="target_type")
    private Integer targetType;//目标类型 0：员工  1：群聊

    @Column(name="target_id")
    private Integer targetId;

    @Column(name="agreement")
    private String agreement;//协议 0：文本  1：图片   2：音频    3：视频  4：其他文件

    @Column(name="content")
    private String content;//文本内容   图片url  音频url   视频url         其他文件url

    @Column(name="time")
    private String time;//发送时间

    @JsonIgnore
    @ToString.Exclude
    @ManyToOne(cascade = { CascadeType.PERSIST})//级联操作
    @JoinColumn(name="new_user_id")//消息所属人id
    private User ownUser = new User();

    @Override
    public String toString() {
        return "News{" +
                "id=" + id +
                ", sourceId=" + sourceId +
                ", targetType=" + targetType +
                ", targetId=" + targetId +
                ", agreement='" + agreement + '\'' +
                ", content='" + content + '\'' +
                ", time='" + time + '\'' +
                '}';
    }
}
